package net.itren.jetpackdemo.ui

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import androidx.lifecycle.Observer
import kotlinx.android.synthetic.main.activity_two.*
import net.itren.jetpackdemo.R
import net.itren.jetpackdemo.model.MainModel

class TwoActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_two)
        Log.e(this.javaClass.name, "页面启动")
        val mailModel = MainModel()
        changeDate.setOnClickListener {
            Log.e(this.javaClass.name, "改变内容")

            mailModel.setMyString("哈哈哈, 饿哦偷偷改变了东西");
        }
        mailModel.getMyString().observe(this, Observer<String> {
            changeDate.text = it;
        })

    }
}